package com.giraffe.mqtt.controller;

import com.giraffe.mqtt.service.MqttService;
import com.google.common.collect.Maps;
import io.netty.handler.codec.mqtt.MqttQoS;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author ldx
 * @Date 2024/01/17 15:15
 **/
@RestController
@RequestMapping("test")
public class TestController {

    public static Map<String,String> m = Maps.newHashMap();
    @Resource
    MqttService mqttService;

    @GetMapping("send")
    public void send(@RequestParam("topic") String topic){
        System.out.println("send");
        mqttService.push(topic, MqttQoS.AT_MOST_ONCE,m.get(topic).getBytes(),false);
    }


}
